package com.util;

import com.javabean.Student;
import mapper.StudentMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class StudentMapperTest {
    SqlSessionFactory sqlSessionFactory;
    SqlSession sqlSession;
    StudentMapper mapper;

    @Before
    public void before() {
        sqlSessionFactory = MyBatisUtil.getSqlSessionFactory();
        sqlSession = sqlSessionFactory.openSession(true);
        mapper = sqlSession.getMapper(StudentMapper.class);
    }

    @After
    public void after() {
        sqlSession.close();
    }

    @Test
    public void selectAll(){
        for (Student student : mapper.selectAll()) {
            System.out.println(student);
        }
    }
    @Test
    public void selectBySid(){
        for (Student student : mapper.selectBySid(1)) {
            System.out.println(student);
        }
    }

}
